﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ChangePassword.aspx.cs" Inherits="Com.CMS263.Web.manage.ManageUser.ChangePassword" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>
     <link href="../style/main.css" rel="stylesheet" type="text/css" />
    <link href="../common/validator.css" rel="stylesheet" type="text/css" />

    <script src="../../js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script src="../../js/common.js" type="text/javascript"></script>
      <% var email = Request.QueryString["email"]; 
      var guid = Request.QueryString["guid"];%>
    <script language="javascript" type="text/javascript">
        function ok() {
//        var flag=false;
//        if ($("#password").val() == "") {
//            $("#passwordSpan").html("<span class=\"Tootip\">密码不能为空！</span>");
//            $("#password").focus();
//            return false;
//        }
//        else {
//            $("#passwordSpan").html("");
//            flag = true;
//        }
            var rePwd =document.getElementById("repassword");
            var pwd = document.getElementById("password");
        var isrepwd = CheckPass(pwd);
        var isPwd = CheckRepassword(rePwd);
        if (isPwd == true && isrepwd == true) {          
             $("#StateSpan").html("");
             $.post("User_action.aspx?op=ChangePassOver", { password: $("#password").val(), email: '<%=email %>', guid: '<%=guid %>' }, function(data) {            
                 if (data == 1) {
                     alert("更改密码成功!");
                     location.href = "Manage_User.aspx";
                 }
                 else {
                     alert("更改失败！");
                     location.href = "Manage_User.aspx";
                 }
             })
           }
       }
       function CheckIsNull(val) {
           var txt = document.getElementById(val.id).value;
           var lblError = document.getElementById("lbl" + val.id);
           var ispass = false;
           if (txt == null || txt == "") {
               lblError.innerHTML = "必填*";
               //val.focus();
               ispass = false;
           }
           else {           
               lblError.style.display = "none";
               ispass = true;
           }
           return ispass;
       }
       function CheckPass(txt) {
           var ispass = CheckIsNull(txt);
           var pass = false;
           if (ispass) {
               var password = document.getElementById(txt.id).value;
               var reg = new RegExp("^([\\w]{6,20})$");
               var lblpassword = document.getElementById("lbl" + txt.id);
               lblpassword.style.display = "inline";
               if (!reg.test(password)) {
                   lblpassword.innerHTML = "只能为英文，字母和数字,并最少6位";

                   pass = false;
               }
               else {
                   lblpassword.style.display = "none";
                   pass = true;
               }

           }
           //        txt.blur();
           //        txt.focus();
           return pass;
       }
       function CheckRepassword(txt) {
           var isnull = CheckIsNull(txt);
           var ispass = false;
           if (isnull) {
               var repassword = document.getElementById(txt.id).value;
               var lblrepassword = document.getElementById("lbl" + txt.id);
               if (CheckPass(txt)) {
                   var password = document.getElementById("password").value;
                   lblrepassword.style.display = "inline";
                   if (password == txt.value) {
                       lblrepassword.style.display = "none";
                       ispass = true;
                   }
                   else {
                       lblrepassword.innerHTML = "两次输入的密码不一致!";
                       ispass = false;
                   }
               }
           }
           //        txt.blur();
           //        txt.focus();
           return ispass;
       }
</script>
</head>
<body>
    <form id="form1" runat="server">
 <table width="96%" border="0" align="center" cellpadding="0" cellspacing="0" class="table_1">
            <tr>
                <td height="23" class="table_2" colspan="3">
                    用户管理
                </td>
            </tr>
            <tr>
          <td class="tdside" colspan="3">
             找回密码</td>
              </tr>
               <tr>
          <td class="tdside" colspan="3">
              <center><b><font color="#666666">请输入您的新密码 </font></b></center>
              </td></tr>
            <tr>
                 <td class="tdside" style=" width:100px; text-align:center;">
                   
           密码:</td><td class="tdside"><span class="CL_mr">
                <input type="password" class="pwd" id="password" name="userpassword" onblur="CheckPass(this)"
                    tabindex="2" /><span id="lblpassword" style="color: Red"></span></span>
                     <%--密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 码:</td><td class="tdside"><input id="password"  type="text" name="password"/><span style="color:red" id="passwordSpan"></span>--%></td>
           <td><%--<span id="StateSpan"></span>--%><span  style="height: 18px; font-size: 12px; line-height: 18px;">
                最多16个字符，只能为英文，字母和数字</span></td>
            </tr>        
             <tr>
                 <td class="tdside" style=" width:100px; text-align:center;">
                   
           确认密码:</td><td class="tdside">
                 <input type="password"id="repassword" onblur="CheckRepassword(this)"  tabindex="3" /><span id="lblrepassword" style="color: Red"></span>
                     <%--密&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 码:</td><td class="tdside"><input id="password"  type="text" name="password"/><span style="color:red" id="passwordSpan"></span>--%></td>
           <td><span  style="height: 18px; font-size: 12px; line-height: 18px;">
                最少为6位</span></td>
            </tr>    
                     <tr><td colspan="3">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                         <input ID="Button1"  value="提 交" type="button"  onclick="ok();"/>
                       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <input type="reset" value="取消" id="cancel"  style="width:50px" /></td></tr>
        </table>
    </form>
</body>
</html>
